package com.yt.fras.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yt.fras.mapper.AttendanceUserMapper;
import com.yt.fras.pojo.base.UserOutputExcel;
import com.yt.fras.pojo.entity.AttendanceUser;
import com.yt.fras.pojo.model.AttendanceUserInfo;
import com.yt.fras.pojo.model.UserInfo;
import com.yt.fras.service.AttendanceUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户考勤记录 服务实现类
 * </p>
 *
 * @author yt
 * @since 2021-10-25
 */
@Service
@CacheConfig(cacheNames = "attendanceUserCache")
public class AttendanceUserServiceImpl extends ServiceImpl<AttendanceUserMapper, AttendanceUser> implements AttendanceUserService {

    @Autowired
    private AttendanceUserMapper attendanceUserMapper;

    @Override
    public List<AttendanceUserInfo> getUserAttendancesByGroup(String userId, String groupId) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("groupId", groupId);
        return attendanceUserMapper.getUserAttendancesByGroup(map);
    }

    @Override
    public List<AttendanceUserInfo> getUserAttendancesByAttendanceId(String attendanceId) {
        return attendanceUserMapper.getUserAttendancesByAttendanceId(attendanceId);
    }

    @Override
    public List<UserInfo> getAttendanceUsers(String attendanceId) {
        return attendanceUserMapper.getAttendanceUsers(attendanceId);
    }

    @Override
    public List<UserOutputExcel> getAbsentUsers(String attendanceId) {
        return attendanceUserMapper.getAbsentUsers(attendanceId);
    }

}
